<#macro examItem exam>
	<div class="col-md-4 well item-${exam.id}">
		<div class="info">
			<span class="id">${exam.id}</span>
			<p class="title"><strong> ${ellipsis(exam.user.email, 15)}</strong></p>
			<p>${ellipsis(exam.profile.title, 20)}</p>
			
			<span class="label"> status
				<#if exam.score gt 69 && exam.pending == false>
					<span class="approved">approved</span>
				<#elseif exam.pending == false>
					<span class="failed">failed</span>
				<#else>
					<span class="not-started">not started</span>
				</#if>
			</span>
			<span class="label"> 
				<span>${exam.score!"0"}%</span>
			</span>
			<span class="label"> questions
				<span> ${exam.questionSize}</span>
			</span>

			<#if !exam.started == true>
				<a href="<@spring.url '/exams/update/${exam.id}' />" class="btn btn-primary">update</a>
			<#else>
				<a class="btn btn-default">cannot be modified</a>

			</#if>
		</div>
		<a class="delete" data-id="${exam.id}"></a>
	</div>
</#macro>

<#macro invalidAlert id=1 string="">
	<div class="alert alert-danger">
		<#if id == 1>
			<strong>Access denied.</strong> You cannot apply current exam. Exam belongs to someone else. Please go back to your account.
		<#elseif id == 2>
			<strong>Error:</strong> We're sorry, there was a problem trying to reach an appropiated question, please contact an administrator.
		<#elseif id = 3>
			<strong>Error:</strong> We're sorry, there was a problem trying to reach question (<strong>with id: ${string}</strong>), please contact an administrator and make him/her aware of it. Thanks.
		<#elseif id = 4>
			<strong>Error:</strong> This exam is not resolved yet.  There is still missing some information to be submitted. Please check back later.
		</#if>
	</div>
</#macro>

<#macro displayQuestion question currQuestionIndex totalQuestion>
	<div class="well question cf" data-id="${question.id}">
		<p><strong>Choose topic: </strong><span>${question.topic.title}</span> </p>
		<#if getList(question.itemsList)?size gt 0>
			<#assign iList = getList(question.itemsList) />
			<div class="body">
				<div class="question-form cf">
					<div class="content">
						<p class="description">
							${question.description}			
						</p>
					</div>
					<form action="<@spring.url '/exams/verifyQuestion/' />" method="POST">
						<div class="form-group expand" data-toggle="buttons">
							<#assign counter = 0 /> 
							<#list iList as i>
								<#assign counter = counter + 1 />
								<label class="answer btn btn-default" data-id="${i.id}">
									<strong>${counter})</strong>
									<input type="<#if question.isMultiple()>checkbox<#else>radio</#if>" name="answer" value="${i.id}" />${i.description}
								</label>
							</#list>
						</div>
						<a class="btn btn-primary submit disabled right" role="button">confirm</a>
					</form>
				</div>
				
			</div>
		<#else>
			<@invalidAlert 3 question.id />
			<div class="next">
				<a data-url="<@spring.url '/exams/getQuestion/' />" class="btn btn-primary btn-next right" role="button">try again</a>
			</div>
		</#if>
		<div class="after cf" style="display:none;">
			<div class="explanation alert alert-warning">
				<p class="description"><strong>Explanation: </strong>${question.explanation}</p>
			</div>
			<div class="next cf" >
				<a data-url="<@spring.url '/exams/getQuestion/' />" class="btn btn-primary btn-next right" role="button">next</a>
			</div>
		</div>
		<p><span class="number">${currQuestionIndex + 1}</span> <strong>of ${totalQuestion}</strong>  </p>
	</div>
</#macro>

<#macro getResult>
	<div class="well">
		<div class="next cf" >
			<p><strong>Well done!</strong> You have already finished this exam. Please procced.</p>
			<a href="<@spring.url '/exams/detail/${m_site.m_exam.id}' />" class="btn btn-primary right" role="button">get result</a>
		</div>
	</div>
</#macro>